﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Wyn.PMS.Common.Utils;
using Wyn.PMS.Entity.Entities;

namespace Wyn.PMS.Common.NightAudit
{
    public class NoShowProcess
    {
        public IList<Order> UpdateNoShowOrders(ICollection<Order> noshowOrders,string employeeId)
        {
            if (noshowOrders == null || noshowOrders.Count <= 0) return null;

            var orders = noshowOrders.Where(o => o.Status == EnumHelper.GetCode(OrderStatus.R)).ToList();

            foreach (var order in orders)
            {
                order.Status = EnumHelper.GetCode(OrderStatus.X);
                order.ModifiedTime = DateTime.Now;
                order.EmployeeID = employeeId;
            }

            return orders;
        }

        public IList<RoomOccupy> UpdateNoShowOccupies(ICollection<RoomOccupy> noShowOccupies, DateTime bizDay, string employeeId)
        {
            if (noShowOccupies == null || noShowOccupies.Count <= 0) return null;

            var occupies=noShowOccupies.Where(o => o.OrderType==(int)OrderType.Reserve && o.IsValid).ToList();

            foreach (var occupy in occupies)
            {
                occupy.IsNoShow = true;
                occupy.IsValid = false;
                occupy.CancelBizDay = bizDay;
                occupy.ModifiedTime = DateTime.Now;
                occupy.EmployeeID = employeeId;
            }

            return occupies;
        }

        public IList<Reservation> UpdateNosShowReservation(IList<Reservation> noShowResvation,string employeeId)
        {
            if (noShowResvation == null || noShowResvation.Count <= 0) return null;
            
            foreach (var resv in noShowResvation)
            {
                resv.Status = EnumHelper.GetCode(ReserveStatus.N);
            }

            return noShowResvation;
        }

    }
}
